package com.example.express.model;

import com.fasterxml.jackson.annotation.JsonIgnore;

import javax.persistence.*;
import java.util.Collection;
import java.util.Objects;

@Entity
public class TransNode {
    private String id;
    private String nodeName;
    private Integer nodeType;
    private String regionCode;
    private String telCode;
    private Double x;
    private Double y;
    private Collection<TransPackage> fromMe;
    private Collection<TransPackage> transPackagesById_0;

    @Id
    @Column(name = "ID")
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Basic
    @Column(name = "NodeName")
    public String getNodeName() {
        return nodeName;
    }

    public void setNodeName(String nodeName) {
        this.nodeName = nodeName;
    }

    @Basic
    @Column(name = "NodeType")
    public Integer getNodeType() {
        return nodeType;
    }

    public void setNodeType(Integer nodeType) {
        this.nodeType = nodeType;
    }

    @Basic
    @Column(name = "RegionCode")
    public String getRegionCode() {
        return regionCode;
    }

    public void setRegionCode(String regionCode) {
        this.regionCode = regionCode;
    }

    @Basic
    @Column(name = "TelCode")
    public String getTelCode() {
        return telCode;
    }

    public void setTelCode(String telCode) {
        this.telCode = telCode;
    }

    @Basic
    @Column(name = "x")
    public Double getX() {
        return x;
    }

    public void setX(Double x) {
        this.x = x;
    }

    @Basic
    @Column(name = "y")
    public Double getY() {
        return y;
    }

    public void setY(Double y) {
        this.y = y;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        TransNode transNode = (TransNode) o;
        return Objects.equals(id, transNode.id) &&
                Objects.equals(nodeName, transNode.nodeName) &&
                Objects.equals(nodeType, transNode.nodeType) &&
                Objects.equals(regionCode, transNode.regionCode) &&
                Objects.equals(telCode, transNode.telCode) &&
                Objects.equals(x, transNode.x) &&
                Objects.equals(y, transNode.y);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, nodeName, nodeType, regionCode, telCode, x, y);
    }

    @JsonIgnore
    @OneToMany(mappedBy = "source")
    public Collection<TransPackage> getFromMe() {
        return fromMe;
    }

    public void setFromMe(Collection<TransPackage> fromMe) {
        this.fromMe = fromMe;
    }

    @JsonIgnore
    @OneToMany(mappedBy = "target")
    public Collection<TransPackage> getTransPackagesById_0() {
        return transPackagesById_0;
    }

    public void setTransPackagesById_0(Collection<TransPackage> transPackagesById_0) {
        this.transPackagesById_0 = transPackagesById_0;
    }
}
